package com.example.study.controller;

import com.example.study.common.api.ResultUtil;
import com.example.study.model.CourseDateVO;
import com.example.study.model.CourseVO;
import com.example.study.model.group.Insert;
import com.example.study.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "课程管理")
@RestController
@RequestMapping("/course")
public class CourseController {

    @Resource
    private CourseService courseService;

    /**
     * 创建课程
     * */
    @ApiOperation("创建课程")
    @RequestMapping(value = "/create_course", method = RequestMethod.POST)
    public ResultUtil createCourse(@RequestBody @Validated(Insert.class) CourseVO courseVO){
        return courseService.createCourse(courseVO);
    }

    /**
     * 创建课程表
     * */
    @ApiOperation("创建课程表")
    @RequestMapping(value = "/create_course_date", method = RequestMethod.POST)
    public ResultUtil createCourseDate(@RequestBody @Validated(Insert.class) CourseDateVO courseDateVO){
        return courseService.createCourseDate(courseDateVO);
    }
}
